home *** CD-ROM | disk | FTP | other *** search
/ Ham Radio 2000 #2 / Ham Radio 2000 - Volume 2.iso / HAMV2 / TCP_IP / TNOS230S / AX25MAIL.C < prev    next >
Encoding:
C/C++ Source or Header  |  1997-07-30  |  2.2 KB  |  90 lines

  1. /* AX25 mailbox interface
  2.  * Copyright 1991 Phil Karn, KA9Q
  3.  *
  4.  *    May '91    Bill Simpson
  5.  *        move to separate file for compilation & linking
  6.  */
  7. #include "global.h"
  8. #include "commands.h"
  9. #include "proc.h"
  10. #include "iface.h"
  11. #include "usock.h"
  12. #include "mailbox.h"
  13. #include "ax25mail.h"
  14.  
  15. #if !defined(_lint)
  16. static char rcsid[] OPTIONAL = "$Id: ax25mail.c,v 1.18 1997/07/31 00:44:20 root Exp root $";
  17. #endif
  18.  
  19. extern int Mbjumpstart;
  20.  
  21.  
  22. /* Axi_sock is kept in Socket.c, so that this module won't be called */
  23. int
  24. ax25start (argc, argv, p)
  25. int argc OPTIONAL;
  26. char *argv[] OPTIONAL;
  27. void *p OPTIONAL;
  28. {
  29. int s, whatcall;
  30. struct usock *up;
  31.  
  32.     if (Axi_sock != -1)
  33.         return 0;
  34.  
  35.     ksignal (Curproc, 0);    /* Don't keep the parser waiting */
  36.     server_disconnect_io ();
  37.     chname (Curproc, "AX25 listener");
  38.     Axi_sock = socket (AF_AX25, SOCK_STREAM, 0);
  39.     /* bind() is done automatically */
  40.     if (listen (Axi_sock, 1) == -1) {
  41.         close_s (Axi_sock);
  42.         return -1;
  43.     }
  44.     for (;;) {
  45.         if ((s = accept (Axi_sock, NULLCHAR, NULLINT)) == -1)
  46.             break;    /* Service is shutting down */
  47.  
  48.         /* Spawn a server */
  49.         up = itop (s);
  50.         if (up == NULLUSOCK || !up->cb.ax25) {    /* shouldn't happen */
  51.             close_s (s);
  52.             continue;
  53.         }
  54.         whatcall = up->cb.ax25->jumpstarted;
  55.         if (whatcall & IP_LINK) {    /* don't start PBBS for IP VC connect */
  56.             continue;
  57.         }
  58.         /* If jumpstart is off, then
  59.          * eat the line that triggered the connection
  60.          * and start the mailbox
  61.          */
  62.         if (!Mbjumpstart) {
  63.             (void) sockmode (s, SOCK_ASCII);    /* To make recvline work */
  64.             (void) recvline (s, (unsigned char *)0, 80);
  65.         } else {
  66.             /* Check to see if jumpstart was actually used for
  67.              * this connection.
  68.              * If not, then again eat the line triggering this all
  69.              */
  70.             if (!(whatcall & JUMPSTARTED)) {
  71.                 (void) sockmode (s, SOCK_ASCII);    /* To make recvline work */
  72.                 (void) recvline (s, (unsigned char *)0, 80);
  73.             }
  74.         }
  75.         if (newproc ("pbbs", 2048, pbbs_incom, s, (void *) whatcall, NULL, 0) == NULLPROC)
  76.             close_s (s);
  77.     }
  78.     return (deleteserver (&Axi_sock));
  79. }
  80.  
  81.  
  82. int
  83. ax250 (argc, argv, p)
  84. int argc OPTIONAL;
  85. char *argv[] OPTIONAL;
  86. void *p OPTIONAL;
  87. {
  88.     return (deleteserver (&Axi_sock));
  89. }
  90.